from gensim.models import Word2Vec

# 加载训练好的 Word2Vec 模型
model = Word2Vec.load('./models/word2vec-v19.model')  # 请根据实际路径调整

# 获取所有词汇
words = model.wv.index_to_key  # 获取词汇列表

# 保存所有词汇到文件
with open('./models/all_words.txt', 'w', encoding='utf-8') as f:
    for word in words:
        f.write(word + '\n')

print(f"导出 {len(words)} 个词汇到 all_words.txt 文件")
